const Org = require('../control/organizetion')

async function createOrganization(req,res){
    const {name,description,username} = req.body;
    let result = await Org.createOrganization(name,description,username);
    res.send(result);
}

async function deleteOrganization(req,res){
    const {org_id,username} = req.body;
    let result = await Org.deleteOrganization(org_id,username);
    res.send(result);
}

async function organizationList(req,res){
    const {page,pageSize,username} = req.query;
    let result = await Org.organizationList(page,pageSize,username);
    res.send(result);
}


async function applicationList(req,res){
    const {page,pageSize,org_id,username} = req.query;
    let result = await Org.applicationList(page,pageSize,org_id,username);
    res.send(result);
}

async function agreeJoins(req,res){
    const {member_ids,org_id,username} = req.body;
    let result = await Org.agreeJoins(member_ids,org_id,username);
    res.send(result);
}

async function refuseJoins(req,res){
    const {member_ids,org_id,username} = req.body;
    let result = await Org.refuseJoins(member_ids,org_id,username);
    res.send(result);
}

async function allOrganizationList(req,res){
    const {page,pageSize} = req.query;
    let result = await Org.allOrganizationList(page,pageSize);
    res.send(result);
}

async function joinedOrganizationList(req,res){
    const {page,pageSize,username} = req.query;
    let result = await Org.joinedOrganizationList(page,pageSize,username);
    res.send(result);
}

async function joinOrganization(req,res){
    const {org_id,username} = req.body;
    let result = await Org.joinOrganization(org_id,username);
    res.send(result);
}

async function quitOrganization(req,res){
    const {org_id,username} = req.body;
    let result = await Org.quitOrganization(org_id,username);
    res.send(result);
}


module.exports = {
    createOrganization,
    deleteOrganization,
    organizationList,
    applicationList,
    agreeJoins,
    refuseJoins,
    allOrganizationList,
    joinedOrganizationList,
    joinOrganization,
    quitOrganization,

}

